package com.hrm.model.daoimple;

import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.hrm.model.dao.CodeDAO;
import com.hrm.model.dto.code.CodeDTO;

public class CodeDAOImple extends SqlMapClientDaoSupport implements CodeDAO{

	@Override
	public List<CodeDTO> getAllCode(CodeDTO dto) {
		return (List<CodeDTO>)this.getSqlMapClientTemplate().queryForList("CodeMap.getAllCode", dto);
	}

	@Override
	public boolean updateCode(CodeDTO dto) {
		try{
			this.getSqlMapClientTemplate().update("CodeMap.updateCodeDetail", dto);
		}catch (Exception e) {
			System.out.println(e.getMessage());
			return false;
		}
		return true;
	}

	@Override
	public int getCodeCount(CodeDTO dto) {
		return (Integer) this.getSqlMapClientTemplate().queryForObject("CodeMap.getCodeCount", dto);
	}

	@Override
	public boolean insertCode(CodeDTO dto) {
		try{
			this.getSqlMapClientTemplate().insert("CodeMap.insertCode", dto);
		}catch (Exception e) {
			System.out.println(e.getMessage());
			return false;
		}
		return true;
	}

	@Override
	public boolean insertDetailCode(CodeDTO dto) {
		try{
			this.getSqlMapClientTemplate().insert("CodeMap.insertCodeDetail", dto);
		}catch (Exception e) {
			System.out.println(e.getMessage());
			return false;
		}
		return true;
	}

	@Override
	public List<CodeDTO> getAllKind() {
		return this.getSqlMapClientTemplate().queryForList("CodeMap.getAllKind");
	}

}
